//
//  WHMainTabBarController.m
//  WHstoreItemProtect
//
//  Created by wztx on 2017/11/4.
//  Copyright © 2017年 sdwh.com. All rights reserved.
//

#import "WHMainTabBarController.h"

#import "WHMainNavigationController.h"

#import "WHPersonageViewController.h"
#import "WHorderListViewController.h"
#import "WHnearbyPlaceViewController.h"
#import "WHlocalLifeViewController.h"

#import "SHintergralStoreViewController.h"

#import "UIColor+Addition.h"

@interface WHMainTabBarController ()

@end

@implementation WHMainTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
}
#pragma MARK - UI
- (void)setupUI
{
    self.view.backgroundColor = [UIColor greenColor];
   
    UIViewController *localController = [self controllerWith:@"WHlocalLifeViewController" title:@"本地生活" imageName:@"bendi"];
    
    UIViewController *nearbyController = [self controllerWith:@"WHnearbyPlaceViewController" title:@"附近" imageName:@"fujin"];
    
    UIViewController *intergralController = [self controllerWith:@"SHintergralStoreViewController" title:@"积分商城" imageName:@"shangcehng"];
    
    UIViewController *orderController = [self controllerWith:@"WHorderListViewController" title:@"订单" imageName:@"list"];
    
    UIViewController *personController = [self controllerWith:@"WHPersonageViewController" title:@"个人中心" imageName:@"person"];
    
    self.viewControllers = @[localController,nearbyController,intergralController,orderController,personController];
    
}
#pragma mark - 抽取分类
-(UIViewController *)controllerWith:(NSString *)className title:(NSString *)title imageName:(NSString *)imageName{
    Class clz = NSClassFromString(className);
    UIViewController *controller = [[clz alloc]init];
    return [self controller:controller WithTitle:title imageName:imageName];
}
- (UIViewController *)controller:(UIViewController *)controller WithTitle:(NSString *)title imageName:(NSString *)imageName{
    controller.title = title;
    self.tabBar.tintColor = [UIColor colorWithHex:0xFF6800];
    controller.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    controller.tabBarItem.selectedImage = [[UIImage imageNamed:[NSString stringWithFormat:@"%@-active",imageName]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    WHMainNavigationController *navController = [[WHMainNavigationController alloc]initWithRootViewController:controller];
    return navController;
}


@end
